package service.impl;

import dao.MyUserDao;
import org.springframework.stereotype.Service;
import pojo.MyUser;
import service.MyUserService;

import javax.annotation.Resource;
import java.util.UUID;

@Service
public class MyUserServiceImpl implements MyUserService {

    @Resource
    private MyUserDao myUserDao;

    public int add(MyUser myUser) {
        myUser.setId(UUID.randomUUID().toString());
        return myUserDao.add(myUser);
    }

    public String login(MyUser user) {
        MyUser myUser = myUserDao.get(user.getUname());
        if (myUser==null){
            return "user not exist";
        }
        if (!myUser.getPsd().equals(user.getPsd())){
            return "wrong psd";
        }
        return "success";
    }
}
